from socket import *
import time
import pygame
import sys

pygame.init()
screen=pygame.display.set_mode((50,50))
addr="127.0.0.1"
mysock=socket(AF_INET, SOCK_DGRAM)
mysock2=socket(AF_INET, SOCK_DGRAM)
mysock2.bind(("127.0.0.1",2203))
mysock2.setblocking(0)
data=""
while 1:
    for event in pygame.event.get():
        if event.type==pygame.KEYDOWN and event.key==pygame.K_SPACE:
            print "working"
            mysock.sendto("@karl", (addr,2202))
            mysock.sendto("Bhi", (addr,2202))
        if event.type==pygame.QUIT:
            sys.exit()
    try:
        data,addr=mysock2.recvfrom(1024)
    except:
        pass
    if data is not "":
        print data
